<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>驴妈妈流立方</title>
		<meta name="description" content="overview &amp; stats" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap.min.css" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/font-awesome/4.5.0/css/font-awesome.min.css" />
		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/daterangepicker.min.css" />
		<!-- text fonts -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/fonts.googleapis.com.css" />
		<!-- ace styles -->
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace-skins.min.css" />
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace-rtl.min.css" />
		
		<link rel="stylesheet" href="${rc.contextPath}/assets/css/jquery.gritter.min.css" />
		<!-- ace settings handler -->
		<script src="${rc.contextPath}/assets/js/ace-extra.min.js"></script>
	   <link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap-datetimepicker.min.css" />
	  <!--   <link rel="stylesheet" href="${rc.contextPath}/assets/css/chosen.min.css" /> -->
	  <link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap.css" /> 
	  <link rel="stylesheet" href="${rc.contextPath}/assets/css/bsie-paginator.css" />
	</head>
	<body class="skin-2" style="background-color: #FFF;">
		<div class="page-content">

			<div class="row">
				<div class="col-sm-12">
					<div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
						<div class="row">
							<form class="form-inline" id="searchForm" method="post" action="${rc.contextPath}/robot/ajaxMongoData">
								<div class="col-sm-12">
								<div class="row">
								<div class="col-sm-1">
								</div>
								<div class="col-sm-5">
									<div class="form-group">
										<label >命中情况</label>
											<select name="isMatch" id="isMatch" class="chosen-select" data-placeholder="" tabindex="2" >
												<#list condition.hitList as hit>
													<option value="${hit.value}" <#if condition.isMatch == hit.value>selected</#if>>${hit.showName}</option>
												</#list>
											</select>
									</div>
									<div class="form-group">
										<label >服务商</label>
											<select name="source" id="source" class="chosen-select" data-placeholder="" tabindex="2" >
												<option value="all" <#if condition.source == "all">selected</#if>>全部</option>
												<option value="eai" <#if condition.source == "eai">selected</#if>>EAI</option>
												<option value="es"  <#if condition.source == "es">selected</#if>>ES</option>
												<option value="turing" <#if condition.source == "turing">selected</#if>>turing</option>
												<option value="self"  <#if condition.source == "self">selected</#if>>self</option>
											</select>
									</div>
									<br><br>
								<div>
								<div class="form-group">
										<label>开始时间
											<input type="text" class="form-control datetimepicker" id="beginDate" name="beginDate" value="${condition.beginDate!}" placeholder="查询开始时间">
										</label>
								</div>
								<div class="form-group">
										<label>结束时间
											<input type="text" class="form-control datetimepicker" id="endDate" name="endDate" value="${condition.endDate!}" placeholder="查询结束时间">
										</label>
								</div>
								</div>
								<br>
								<input type="text" name="page" id="page1" hidden="true">
								<div class="form-group">
										<button type="button" class="btn btn-pink btn-sm" id="search">
											<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
											查询
										</button>
								</div>
								<div class="form-group">
										<button type="button" class="btn btn-pink btn-sm" id="export">
											导出excel
										</button>
								</div>
								</div>
								<div class="col-sm-6">
									<div id="container2" ></div>
								</div>
								</div>
							</div>
							</form>
							<form action="${rc.contextPath}/robot/exportMongoData"  method="post" hidden="true">
								<input type="text" name="isMatch" hidden="true" id="isMatch1">
								<input type="text" name="beginDate" hidden="true" id="beginDate1">
								<input type="text" name="endDate" hidden="true" id="endDate1">
								<input type="text" name="source" hidden="true" id="source1">
								<button type="submit" hidden="true" id="exportExcel" class="btn btn-primary" ></button>
							</form>
						</div>
						<table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dynamic-table_info">
							<thead>
								<tr>
									<th>No.</th>
									<th>sessionId</th>
									<!-- <th>手机号</th> -->
									<th>问题</th>
									<th>回答</th>
									<th>是否命中</th>
									<th>服务商</th>
									<th>创建时间</th>
								</tr>
							</thead>
							<tbody>
								<#if mongos?? && mongos?size&gt;0>
									<#list mongos as mongo>
										<tr class="">
											<td>${mongo_index + 1}</td>
											<td>${mongo.sessionId!}</td>
											<!-- <td>${mongo.mobileNumber!}</td> -->
											<td>${mongo.question!}</td>
											<td>${mongo.answer!}</td>
											<!-- <td>${mongo.status!}</td> -->
											<td><#if mongo.status == "MATCH">命中</#if>
												<#if mongo.status == "NOT_MATCH">未命中</#if>
												<#if mongo.status == "EXCEPTION">异常</#if>
											</td>
											<td>${mongo.source!"暂无"}</td>
											<td>${mongo.createTime?string('yyyy-MM-dd HH:mm:ss')}</td>
										</tr>
									</#list>
								<#else>
									<tr>
										<td colspan="12">
											<div class="alert alert-danger" style="margin-bottom: 0px;" role="alert">没有记录!</div>
										</td>
									</tr>		
								</#if>
							</tbody>
						</table>
						<div class="ui-jqgrid">
							<div id="grid-pager" class="ui-state-default ui-jqgrid-pager ui-corner-bottom" dir="ltr">
								<div id="pg_grid-pager" class="ui-pager-control" role="group">
									<table cellspacing="0" cellpadding="0" border="0" class="ui-pg-table"
										style="width: 100%; table-layout: fixed; height: 100%;" role="row">
										<tbody>
											<tr>
												<td id="grid-pager_left" align="left"></td>
												<td id="grid-pager_center" align="center"
													style="white-space: pre; width: 343px;"><table
														cellspacing="0" cellpadding="0" border="0"
														style="table-layout: auto;" class="ui-pg-table">
														<tbody>
															<tr>
																<td id="first_grid-pager" onclick="showPage(${page.firstPage!})"
																	class="ui-pg-button ui-corner-all <#if page.isFirstPage>ui-state-disabled</#if>"
																	style="cursor: pointer;"><span
																	class="ui-icon ace-icon fa fa-angle-double-left bigger-140"></span></td>
																<td id="prev_grid-pager" onclick="showPage(${page.prePage!})"
																	class="ui-pg-button ui-corner-all <#if page.isFirstPage>ui-state-disabled</#if>"
																	style="cursor: pointer;"><span
																	class="ui-icon ace-icon fa fa-angle-left bigger-140"></span></td>
																<td dir="ltr">Page <input class="ui-pg-input" type="text" id="page"
																	size="2" maxlength="7" value="${page.pageNum!}" role="textbox"> of <span
																	id="sp_1_grid-pager">${page.pages!}</span></td>
																<td id="next_grid-pager" onclick="showPage(${page.nextPage!})" class="ui-pg-button ui-corner-all <#if page.isLastPage>ui-state-disabled</#if>"
																	style="cursor: pointer;"><span
																	class="ui-icon ace-icon fa fa-angle-right bigger-140"></span></td>
																<td id="last_grid-pager" onclick="showPage(${page.lastPage!})" class="ui-pg-button ui-corner-all <#if page.isLastPage>ui-state-disabled</#if>"
																	style="cursor: pointer;"><span
																	class="ui-icon ace-icon fa fa-angle-double-right bigger-140"></span></td>
															</tr>
														</tbody>
													</table>
												</td>
												<td id="grid-pager_right" align="right"><div dir="ltr"
													style="text-align: right" class="ui-paging-info"></div></td>
											</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- <div class="col-sm-4">
					<div id="container2"></div>
				</div> -->
			</div>
		</div>		
		<script src="${rc.contextPath}/assets/js/jquery-2.1.4.min.js"></script>
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='${rc.contextPath}/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>
		<script src="${rc.contextPath}/assets/js/bootstrap.min.js"></script>

		<!-- page specific plugin scripts -->
		<script src="${rc.contextPath}/assets/js/moment.min.js"></script>
		<script src="${rc.contextPath}/assets/js/bootstrap-datetimepicker.min.js"></script>
		<script type="text/javascript" src="${rc.contextPath}/javascripts/echarts.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery.gritter.min.js"></script>
		<!-- ace scripts -->
		<script src="${rc.contextPath}/assets/js/ace-elements.min.js"></script>
		<script src="${rc.contextPath}/assets/js/ace.min.js"></script>
		<script src="${rc.contextPath}/assets/js/jquery.gritter.min.js"></script>
		<!-- user scripts -->
		<script src="${rc.contextPath}/assets/js/user/base.js"></script>	
		<script src="${rc.contextPath}/assets/js/chosen.jquery.js"></script>
		<script src="${rc.contextPath}/assets/js/d3.v3.min.js"></script>
		<script type="text/javascript">
            d3.select(self.frameElement).style("height", "1200px");
			var message = "${message}";
			if(!isEmpty(message)) {
				showMsg(message);
			}
			jQuery(function($) {
				var options = {
						format:'YYYY-MM-DD HH:mm:ss'
				}
				$('.datetimepicker').datetimepicker(options).next().on(ace.click_event, function(){
					$(this).prev().focus();
				});
				
				$("#search").on("click",function(){
					$(this).attr("disabled","true");
					$(this).attr("readOnly","true");
					$("#searchForm").submit();
				});
			})
			var showPage = function(page) {
				$("#page1").val(page);
				$("#searchForm").submit();
			}
			$(function(){
				var beginDate=$("#beginDate").val();
				var endDate=$("#endDate").val();
				 if(beginDate==""&&endDate!=""){
					return;
				} 
				 if(beginDate!=""&&endDate==""){
					return;
				} 
			 $.ajax({
				   url: "${rc.contextPath}/robot/ajaxPie",
				   data: "beginDate="+beginDate+"&endDate="+endDate,
				   success: function(data){
					   $("#container2").empty();
					      option1 = {
				  	    		   /*  title : {
				  	    		        text: '命中率',
				  	    		        x:'center'
				  	    		    }, */
				  	    		    tooltip : {
				  	    		        trigger: 'item',
				  	    		        formatter: "{b} : {c} ({d}%)"
				  	    		    },
				  	    		 	grid : {
			    	    		    	width: '100%',
			    	    		    	height: '100%',
										top:'25%'
			    	    		    },
				  	    		    series : [
				  	    		        {
				  	    		           /*  name: '访问来源', */
				  	    		            type: 'pie',
				  	    		            radius : '50%',
				  	    		            center: ['50%', '50%'],
				  	    		            data:data,
				  	    		            itemStyle: {
				  	    		                emphasis: {
				  	    		                    shadowBlur: 10,
				  	    		                    shadowOffsetX: 0,
				  	    		                    shadowColor: 'rgba(0, 0, 0, 0.5)'
				  	    		                },
			    	    		                normal:{ 
			    	                                label:{ 
			    	                                   show: true, 
			    	                                   formatter: '{b} : {c} ({d}%)' 
			    	                                }, 
			    	                                labelLine :{show:true}
			    	                            } 
				  	    		            }
				  	    		        }
				  	    		    ]
				  	    		};
					      
					  var divhtml="<div class='right' id='main1' style='width:100%;height:300px;'></div>";
			    	      $("#container2").append(divhtml);
			    	if(data !=null && data.length!=0 ){
		    	      var myChart1 = echarts.init(document.getElementById('main1'));
	    	    	  myChart1.setOption(option1);
	    	    	  window.onresize = function(){
	    	    		  myChart1.resize();
				  	  }
			    	  }
					      
				   }
				 });
			});
			$("#export").click(function(){
				var isMatch=$("#isMatch").val();
				var beginDate=$("#beginDate").val();
				var endDate=$("#endDate").val();
				var source=$("#source").val();
				 if(beginDate==""&&endDate!=""){
					 showMsg("请输入开始时间");
						return;
					} 
					 if(beginDate!=""&&endDate==""){
						 showMsg("请输入截止时间");
							return;
						} 
				$("#isMatch1").val(isMatch);
				$("#beginDate1").val(beginDate);
				$("#endDate1").val(endDate);
				$("#source1").val(source);
				$("#exportExcel").click();
			})
			$(window).keydown(function(event){
			  if(event.keyCode=="13") {
				  var page=$("#page").val();
				  $("#page1").val(page);
				  $("#searchForm").submit();
			  }
			});
			
			$(".chosen-select").chosen({
			    no_results_text: "没有找到",//搜索无结果时显示的提示
			    search_contains:true,   //关键字模糊搜索，设置为false，则只从开头开始匹配
			    allow_single_deselect:true, //是否允许取消选择
			    max_selected_options:6  //当select为多选时，最多选择个数
			});
		</script>
	</body>
</html>